#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.3.8.1
 Author:         myName

 Script Function:
	Template AutoIt script.

#ce ----------------------------------------------------------------------------

Global Const $log_path = @WorkingDir & "\log"
;Global Const $log_path = @WorkingDir
Global $log_cnt = 1000

Func load_file($file)
	Local $fh = FileOpen($file)
	Local $map[$row_length][$col_length]
	Local $r = 0
	While True
		Local $line = FileReadLine($fh)
		Local $e = @error
		set_label("load " & $r & ": " & $line)
		If $e = -1 Then ExitLoop
		Local $row = StringRegExp($line,"(\d)",3)
		If @error = 0 Then
			If UBound($row,1) = $col_length Then
				For $c = 0 To $col_length - 1
					$map[$r][$c] = $row[$c]
				Next
			Else
				MsgBox(4096,"error","bad line " & $r & ": " & $line & " ub=" & UBound($row,1))
				ExitLoop
			EndIf
			$r += 1
			If $r = $row_length Then ExitLoop
		EndIf
	WEnd
	FileClose($fh)
	If $r = $row_length Then
		;MsgBox(4096,"ok","all good")
		show_map($map)
	Else
		MsgBox(4096,"error","not full row " & $r)
	EndIf
EndFunc

Func store_log($str, $f = False)
	Local $file = $log_path & "\log-" & $log_cnt & ".txt"
	If $f Then
		$file = $f
	Else
		$file = $log_path & "\map-" & @YEAR & "-" & @MON & "-" & @MDAY & "-" & @HOUR & "-" & @MIN & "-" & @SEC & "-" & @MSEC & ".txt"
	EndIf
	Local $fh = FileOpen($file,BitOr(2,256))
	set_label("save to " & $file)
	FileWrite($fh,$str)
	FileClose($fh)
EndFunc

Func map_to_str(ByRef $map)
	Local $str = ""
	For $r = 0 To $row_length - 1
		For $c = 0 To $col_length - 1
			Local $v = $map[$r][$c]
			$str &= $field[$v][0]
		Next
		$str &= @CRLF
	Next
	Return $str
EndFunc

Func award_to_str(ByRef $award)
	Local $str = " "
	$str &= StringFormat("%2d ",$award[$l_award + 1])
	$str &= " "
	$str &= StringFormat("%d-%2d", $award[$l_award + 3], $award[$l_award + 2])
	$str &= " "
	$str &= "["
	For $a = 0 To $l_award
		$str &= StringFormat("%2d",$award[$a])
		If $a <> $l_award Then
			$str &= " "
		EndIf
	Next
	$str &= "]"
	$str &= " "
	;$str &= "("
	For $a = 4 To 7
		$str &= StringFormat("%5.1f",$award[$l_award + $a]*100)
		If $a <> 7 Then
			$str &= ", "
		EndIf
	Next
	Local $m = $award[10]
	If IsArray($m) Then
		$str &= "|"
		for $i = 0 To UBound($m) - 1
			$str &= StringFormat(" %2d",$m[$i])
		Next
	EndIf
	Return $str
EndFunc
